package Lambdemo;



//无返回值无参数  ===================================================
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}

//无返回值一个参数       --------------------------
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}

//无返回值多个参数        +++++++++++++++++++++++++++
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}

//有返回值无参数         \\\\\\\\\\\\\\\\\\\\\
@FunctionalInterface
interface NoParameterReturn {
    int test();
}

//有返回值一个参数          ******************
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}

//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}
public class Test
{
    public static void main(String[] args) {
        MoreParameterReturn moreParameterReturn = (int a , int b) -> a * b;
        int num2 = moreParameterReturn.test(7,5);
        System.out.println(num2);
    }

    public static void main6(String[] args) {
        OneParameterReturn oneParameterReturn = (b) -> b+8;
        int ret= oneParameterReturn.test(8);
        System.out.println(ret);
    }

    public static void main5(String[] args) {
        NoParameterReturn noParameterReturn = () -> {return 100;};
        int num = noParameterReturn.test();
        System.out.println(num);
    }


    public static void main4(String[] args) {
        MoreParameterNoReturn moreParameterNoReturn = (int a , int b) ->{System.out.println(a + b);};
        moreParameterNoReturn.test(11,12);
    }

    public static void main3(String[] args) {
        OneParameterNoReturn oneParameterNoReturn = (int a) -> {System.out.println(a+100);};
        oneParameterNoReturn.test(10);
    }


    public static void main2(String[] args) {
        //写法2:lambda表达式
        NoParameterNoReturn noParameterNoReturn = () -> {System.out.println("test()..");};
        noParameterNoReturn.test();
    }
    public static void main1(String[] args) {
        //定义一个引用接收匿名内部类对象
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("test()..");
            }
        };

        //通过引用调用匿名内部类方法
        noParameterNoReturn.test();
    }
}

